﻿#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Media;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System.Diagnostics;
using System.IO;
#endregion UsingStatements

namespace CakeRaid
{
    class Tower_Shock : Tower
    {
        #region Constructor
        public Tower_Shock(ImageObject io, float fireRadius, int health, int cost, int damage, float speed, float bSpeed, Texture2D bt, Attacktype attackType)
            : base(io, fireRadius, health, cost, damage, speed, bSpeed, bt, attackType)
        {
            type = Var.TowerType.Shock;
            StartHealth = CurrentHealth = Var.SHOCK_TOWER_HEALTH;
        }
        #endregion Constructor

        #region Methods
        public override void Activate()
        {
            if (!placing && IsActive && (eventTimer.ElapsedMilliseconds >= (Speed / Var.GAME_SPEED)))
            {
                if (enemiesInRange.Count > 0)
                {
                    foreach(Enemy e in enemiesInRange)
                    {
                        e.Hit(Damage);
                        e.ApplyStatus(Var.StatusType.Shocked);
                    }
                    enemiesInRange.Clear();
                }
                eventTimer.Restart();
            }
        }
        #endregion Methods

        #region Draw
        public override void Draw(GameTime gameTime)
        {
            if (IsActive)
            {
                if (CurrentHealth > ((Var.SHOCK_TOWER_HEALTH / 4) * 3) && CurrentHealth <= Var.SHOCK_TOWER_HEALTH)
                {
                    base.Draw(0, 0);
                }
                else if (CurrentHealth > ((Var.SHOCK_TOWER_HEALTH / 4) * 2) && CurrentHealth <= ((Var.SHOCK_TOWER_HEALTH / 4) * 3))
                {
                    base.Draw(1, 0);
                }
                else if (CurrentHealth > ((Var.SHOCK_TOWER_HEALTH / 4) * 1) && CurrentHealth <= ((Var.SHOCK_TOWER_HEALTH / 4) * 2))
                {
                    base.Draw(2, 0);
                }
                else if (CurrentHealth > 0 && CurrentHealth <= ((Var.SHOCK_TOWER_HEALTH / 4) * 1))
                {
                    base.Draw(3, 0);
                }
                healthBar.Draw();
            }
        }
        #endregion Draw
    }
}
